<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let form = {
        student: {
          id: '2'
        }
      }
      window.form = form
      //
      /**
       * @description: 获取 多重.的值
       * @param {*}
       * @return {*}
       */
      function test() {
        let ids = ['form', 'student', 'id']
        const len = ids.length
        
        if (len === 0) {
          return
        }
        let self = window
        if (len > 1) {
          for (let i = 0; i < len - 1; i++) {
            self = self[ids[i]]
          }
        }
        return self[ids[len - 1]]
      }
      console.log(test())
    </script>
  </body>
</html>
